home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / QD3DMath.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  26.3 KB  |  916 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DMath.h                                                 **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Math & matrix routines and definitions.                     **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1997 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          ** 
  13.  *****************************************************************************/
  14. #ifndef QD3DMath_h
  15. #define QD3DMath_h
  16.  
  17. #include "QD3D.h"
  18.  
  19. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  20.     #pragma once
  21. #endif  /*  PRAGMA_ONCE  */
  22.  
  23. #include <math.h>
  24. #include <float.h>
  25.  
  26. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  27.  
  28. #if defined(__xlc__) || defined(__XLC121__)
  29.     #pragma options enum=int
  30.     #pragma options align=power
  31. #elif defined(__MWERKS__)
  32.     #pragma enumsalwaysint on
  33.     #pragma options align=native
  34. #elif defined(__MRC__) || defined(__SC__)
  35.     #if __option(pack_enums)
  36.         #define PRAGMA_ENUM_RESET_QD3DMATH 1
  37.     #endif
  38.     #pragma options(!pack_enums)
  39.     #pragma options align=power
  40. #endif
  41.  
  42. #endif  /* OS_MACINTOSH */
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif    /* __cplusplus */
  47.  
  48. /******************************************************************************
  49.  **                                                                             **
  50.  **                            Constant Definitions                             **
  51.  **                                                                             **
  52.  *****************************************************************************/
  53. /*
  54.  *  Real zero definition
  55.  */
  56. #ifdef FLT_EPSILON
  57. #    define kQ3RealZero            (FLT_EPSILON)
  58. #else
  59. #    define kQ3RealZero            ((float)1.19209290e-07)            
  60. #endif  /*  FLT_EPSILON  */
  61.  
  62. #ifdef FLT_MAX
  63. #    define    kQ3MaxFloat            (FLT_MAX)
  64. #else
  65. #    define    kQ3MaxFloat            ((float)3.40282347e+38)
  66. #endif  /*  FLT_MAX  */
  67.  
  68. /*
  69.  *  Values of PI
  70.  */
  71. #define kQ3Pi                     ((float)3.1415926535898)
  72. #define kQ32Pi                     ((float)(2.0 * 3.1415926535898))
  73. #define kQ3PiOver2                ((float)(3.1415926535898 / 2.0))
  74. #define kQ33PiOver2                ((float)(3.0 * 3.1415926535898 / 2.0))
  75.  
  76.  
  77. /******************************************************************************
  78.  **                                                                             **
  79.  **                            Miscellaneous Functions                             **
  80.  **                                                                             **
  81.  *****************************************************************************/
  82.  
  83. #define Q3Math_DegreesToRadians(x)    ((float)((x) * kQ3Pi / 180.0))
  84. #define Q3Math_RadiansToDegrees(x)    ((float)((x) * 180.0 / kQ3Pi))
  85.  
  86. #define Q3Math_Min(x,y)                ((x) <= (y) ? (x) : (y))
  87. #define Q3Math_Max(x,y)                ((x) >= (y) ? (x) : (y))
  88.  
  89.         
  90. /******************************************************************************
  91.  **                                                                             **
  92.  **                            Point and Vector Creation                         **
  93.  **                                                                             **
  94.  *****************************************************************************/
  95.  
  96. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3Point2D_Set(
  97.     TQ3Point2D                    *point2D,
  98.     float                        x, 
  99.     float                        y);
  100.  
  101. QD3D_EXPORT TQ3Param2D *QD3D_CALL Q3Param2D_Set(
  102.     TQ3Param2D                    *param2D,
  103.     float                        u, 
  104.     float                        v);
  105.  
  106. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point3D_Set(
  107.     TQ3Point3D                    *point3D,
  108.     float                        x, 
  109.     float                        y, 
  110.     float                        z);
  111.  
  112. QD3D_EXPORT TQ3RationalPoint3D *QD3D_CALL Q3RationalPoint3D_Set(
  113.     TQ3RationalPoint3D            *point3D,
  114.     float                        x, 
  115.     float                        y, 
  116.     float                        w);
  117.     
  118. QD3D_EXPORT TQ3RationalPoint4D *QD3D_CALL Q3RationalPoint4D_Set(
  119.     TQ3RationalPoint4D            *point4D,
  120.     float                        x,
  121.     float                        y,
  122.     float                        z, 
  123.     float                        w);
  124.     
  125. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector2D_Set(
  126.     TQ3Vector2D                    *vector2D,
  127.     float                        x, 
  128.     float                        y);
  129.  
  130. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Set(
  131.     TQ3Vector3D                    *vector3D,
  132.     float                        x, 
  133.     float                        y, 
  134.     float                        z);
  135.  
  136. QD3D_EXPORT TQ3PolarPoint *QD3D_CALL Q3PolarPoint_Set(
  137.     TQ3PolarPoint                *polarPoint,
  138.     float                        r,
  139.     float                        theta);
  140.  
  141. QD3D_EXPORT TQ3SphericalPoint *QD3D_CALL Q3SphericalPoint_Set(
  142.     TQ3SphericalPoint            *sphericalPoint,
  143.     float                        rho,
  144.     float                        theta,
  145.     float                        phi);
  146.     
  147.     
  148. /******************************************************************************
  149.  **                                                                             **
  150.  **                    Point and Vector Dimension Conversion                     **
  151.  **                                                                             **
  152.  *****************************************************************************/
  153.  
  154. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point2D_To3D(
  155.     const TQ3Point2D            *point2D,
  156.     TQ3Point3D                    *result);
  157.  
  158. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3RationalPoint3D_To2D(
  159.     const TQ3RationalPoint3D    *point3D,
  160.     TQ3Point2D                    *result);
  161.     
  162. QD3D_EXPORT TQ3RationalPoint4D *QD3D_CALL Q3Point3D_To4D(
  163.     const TQ3Point3D            *point3D,
  164.     TQ3RationalPoint4D            *result);
  165.  
  166. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3RationalPoint4D_To3D(
  167.     const TQ3RationalPoint4D    *point4D,
  168.     TQ3Point3D                    *result);
  169.  
  170. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector2D_To3D(
  171.     const TQ3Vector2D            *vector2D,
  172.     TQ3Vector3D                    *result);
  173.     
  174. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector3D_To2D(
  175.     const TQ3Vector3D            *vector3D,
  176.     TQ3Vector2D                    *result);
  177.  
  178.     
  179. /******************************************************************************
  180.  **                                                                             **
  181.  **                            Point Subtraction                                 **
  182.  **                                                                             **
  183.  *****************************************************************************/
  184.  
  185. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Point2D_Subtract(
  186.     const TQ3Point2D            *p1, 
  187.     const TQ3Point2D            *p2,
  188.     TQ3Vector2D                    *result);
  189.  
  190. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Param2D_Subtract(
  191.     const TQ3Param2D            *p1, 
  192.     const TQ3Param2D            *p2,
  193.     TQ3Vector2D                    *result);
  194.  
  195. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Point3D_Subtract(
  196.     const TQ3Point3D            *p1, 
  197.     const TQ3Point3D            *p2,
  198.     TQ3Vector3D                    *result);
  199.     
  200.     
  201. /******************************************************************************
  202.  **                                                                             **
  203.  **                            Point Distance                                     **
  204.  **                                                                             **
  205.  *****************************************************************************/
  206.     
  207. QD3D_EXPORT float QD3D_CALL Q3Point2D_Distance(
  208.     const TQ3Point2D            *p1, 
  209.     const TQ3Point2D            *p2);
  210.  
  211. QD3D_EXPORT float QD3D_CALL Q3Point2D_DistanceSquared(
  212.     const TQ3Point2D            *p1, 
  213.     const TQ3Point2D            *p2);
  214.  
  215.  
  216. QD3D_EXPORT float QD3D_CALL Q3Param2D_Distance(
  217.     const TQ3Param2D            *p1, 
  218.     const TQ3Param2D            *p2);
  219.  
  220. QD3D_EXPORT float QD3D_CALL Q3Param2D_DistanceSquared(
  221.     const TQ3Param2D            *p1, 
  222.     const TQ3Param2D            *p2);
  223.     
  224.     
  225. QD3D_EXPORT float QD3D_CALL Q3RationalPoint3D_Distance(
  226.     const TQ3RationalPoint3D    *p1, 
  227.     const TQ3RationalPoint3D    *p2);
  228.     
  229. QD3D_EXPORT float QD3D_CALL Q3RationalPoint3D_DistanceSquared(
  230.     const TQ3RationalPoint3D    *p1, 
  231.     const TQ3RationalPoint3D    *p2);
  232.  
  233.  
  234. QD3D_EXPORT float QD3D_CALL Q3Point3D_Distance(
  235.     const TQ3Point3D            *p1, 
  236.     const TQ3Point3D            *p2);
  237.  
  238. QD3D_EXPORT float QD3D_CALL Q3Point3D_DistanceSquared(
  239.     const TQ3Point3D            *p1, 
  240.     const TQ3Point3D            *p2);
  241.  
  242.  
  243. QD3D_EXPORT float QD3D_CALL Q3RationalPoint4D_Distance(
  244.     const TQ3RationalPoint4D    *p1, 
  245.     const TQ3RationalPoint4D    *p2);
  246.  
  247. QD3D_EXPORT float QD3D_CALL Q3RationalPoint4D_DistanceSquared(
  248.     const TQ3RationalPoint4D    *p1, 
  249.     const TQ3RationalPoint4D    *p2);
  250.  
  251.  
  252. /******************************************************************************
  253.  **                                                                             **
  254.  **                            Point Relative Ratio                             **
  255.  **                                                                             **
  256.  *****************************************************************************/
  257.  
  258. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3Point2D_RRatio(
  259.     const TQ3Point2D            *p1,
  260.     const TQ3Point2D            *p2,
  261.     float                        r1,
  262.     float                        r2,
  263.     TQ3Point2D                    *result);
  264.  
  265. QD3D_EXPORT TQ3Param2D *QD3D_CALL Q3Param2D_RRatio(
  266.     const TQ3Param2D            *p1,
  267.     const TQ3Param2D            *p2,
  268.     float                        r1,
  269.     float                        r2,
  270.     TQ3Param2D                    *result);
  271.  
  272. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point3D_RRatio(
  273.     const TQ3Point3D            *p1,
  274.     const TQ3Point3D            *p2,
  275.     float                        r1,
  276.     float                        r2,
  277.     TQ3Point3D                    *result);
  278.  
  279. QD3D_EXPORT TQ3RationalPoint4D *QD3D_CALL Q3RationalPoint4D_RRatio(
  280.     const TQ3RationalPoint4D    *p1,
  281.     const TQ3RationalPoint4D    *p2,
  282.     float                        r1,
  283.     float                        r2,
  284.     TQ3RationalPoint4D            *result);
  285.                         
  286.                         
  287. /******************************************************************************
  288.  **                                                                             **
  289.  **                    Point / Vector Addition    & Subtraction                     **
  290.  **                                                                             **
  291.  *****************************************************************************/
  292.  
  293. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3Point2D_Vector2D_Add(
  294.     const TQ3Point2D            *point2D, 
  295.     const TQ3Vector2D            *vector2D,
  296.     TQ3Point2D                    *result);
  297.  
  298. QD3D_EXPORT TQ3Param2D *QD3D_CALL Q3Param2D_Vector2D_Add(
  299.     const TQ3Param2D            *param2D, 
  300.     const TQ3Vector2D            *vector2D,
  301.     TQ3Param2D                    *result);
  302.  
  303. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point3D_Vector3D_Add(
  304.     const TQ3Point3D            *point3D, 
  305.     const TQ3Vector3D            *vector3D,
  306.     TQ3Point3D                    *result);
  307.  
  308. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3Point2D_Vector2D_Subtract(
  309.     const TQ3Point2D            *point2D, 
  310.     const TQ3Vector2D            *vector2D,
  311.     TQ3Point2D                    *result);
  312.  
  313. QD3D_EXPORT TQ3Param2D *QD3D_CALL Q3Param2D_Vector2D_Subtract(
  314.     const TQ3Param2D            *param2D, 
  315.     const TQ3Vector2D            *vector2D,
  316.     TQ3Param2D                    *result);
  317.  
  318. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point3D_Vector3D_Subtract(
  319.     const TQ3Point3D            *point3D, 
  320.     const TQ3Vector3D            *vector3D,
  321.     TQ3Point3D                    *result);
  322.  
  323.  
  324. /******************************************************************************
  325.  **                                                                             **
  326.  **                                Vector Scale                                 **
  327.  **                                                                             **
  328.  *****************************************************************************/
  329.                         
  330. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector2D_Scale(
  331.     const TQ3Vector2D            *vector2D, 
  332.     float                        scalar,
  333.     TQ3Vector2D                    *result);
  334.  
  335. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Scale(
  336.     const TQ3Vector3D            *vector3D, 
  337.     float                        scalar,
  338.     TQ3Vector3D                    *result);
  339.  
  340.     
  341. /******************************************************************************
  342.  **                                                                             **
  343.  **                                Vector Length                                 **
  344.  **                                                                             **
  345.  *****************************************************************************/
  346.  
  347. QD3D_EXPORT float QD3D_CALL Q3Vector2D_Length(
  348.     const TQ3Vector2D             *vector2D);
  349.  
  350. QD3D_EXPORT float QD3D_CALL Q3Vector3D_Length(
  351.     const TQ3Vector3D            *vector3D);
  352.  
  353.     
  354. /******************************************************************************
  355.  **                                                                             **
  356.  **                                Vector Normalize                             **
  357.  **                                                                             **
  358.  *****************************************************************************/
  359.  
  360. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector2D_Normalize(
  361.     const TQ3Vector2D            *vector2D,
  362.     TQ3Vector2D                    *result);
  363.  
  364. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Normalize(
  365.     const TQ3Vector3D            *vector3D,
  366.     TQ3Vector3D                    *result);
  367.  
  368.  
  369. /******************************************************************************
  370.  **                                                                             **
  371.  **                    Vector/Vector Addition and Subtraction                     **
  372.  **                                                                             **
  373.  *****************************************************************************/
  374.  
  375. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector2D_Add(
  376.     const TQ3Vector2D            *v1, 
  377.     const TQ3Vector2D            *v2,
  378.     TQ3Vector2D                    *result);
  379.  
  380. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Add(
  381.     const TQ3Vector3D            *v1, 
  382.     const TQ3Vector3D            *v2, 
  383.     TQ3Vector3D                    *result);
  384.  
  385.  
  386. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector2D_Subtract(
  387.     const TQ3Vector2D            *v1, 
  388.     const TQ3Vector2D            *v2, 
  389.     TQ3Vector2D                    *result);
  390.  
  391. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Subtract(
  392.     const TQ3Vector3D            *v1, 
  393.     const TQ3Vector3D            *v2,
  394.     TQ3Vector3D                    *result);
  395.  
  396.  
  397. /******************************************************************************
  398.  **                                                                             **
  399.  **                                Cross Product                                 **
  400.  **                                                                             **
  401.  *****************************************************************************/
  402.  
  403. QD3D_EXPORT float QD3D_CALL Q3Vector2D_Cross(
  404.     const TQ3Vector2D            *v1, 
  405.     const TQ3Vector2D            *v2);
  406.  
  407. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Cross(
  408.     const TQ3Vector3D            *v1, 
  409.     const TQ3Vector3D            *v2,
  410.     TQ3Vector3D                    *result);
  411.     
  412. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Point3D_CrossProductTri(
  413.     const TQ3Point3D             *point1, 
  414.     const TQ3Point3D             *point2, 
  415.     const TQ3Point3D             *point3, 
  416.     TQ3Vector3D                 *crossVector);
  417.  
  418.  
  419. /******************************************************************************
  420.  **                                                                             **
  421.  **                                Dot Product                                     **
  422.  **                                                                             **
  423.  *****************************************************************************/
  424.  
  425. QD3D_EXPORT float QD3D_CALL Q3Vector2D_Dot(
  426.     const TQ3Vector2D            *v1, 
  427.     const TQ3Vector2D            *v2);
  428.  
  429. QD3D_EXPORT float QD3D_CALL Q3Vector3D_Dot(
  430.     const TQ3Vector3D            *v1, 
  431.     const TQ3Vector3D            *v2);
  432.  
  433.  
  434. /******************************************************************************
  435.  **                                                                             **
  436.  **                        Point and Vector Transformation                         **
  437.  **                                                                             **
  438.  *****************************************************************************/
  439.  
  440. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector2D_Transform(
  441.     const TQ3Vector2D            *vector2D,
  442.     const TQ3Matrix3x3             *matrix3x3,
  443.     TQ3Vector2D                    *result);
  444.     
  445. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Transform(
  446.     const TQ3Vector3D            *vector3D,
  447.     const TQ3Matrix4x4            *matrix4x4,
  448.     TQ3Vector3D                    *result);
  449.  
  450. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3Point2D_Transform(
  451.     const TQ3Point2D             *point2D,
  452.     const TQ3Matrix3x3            *matrix3x3,
  453.     TQ3Point2D                    *result);
  454.  
  455. QD3D_EXPORT TQ3Param2D *QD3D_CALL Q3Param2D_Transform(
  456.     const TQ3Param2D             *param2D,
  457.     const TQ3Matrix3x3            *matrix3x3,
  458.     TQ3Param2D                    *result);
  459.  
  460. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point3D_Transform(
  461.     const TQ3Point3D            *point3D,
  462.     const TQ3Matrix4x4            *matrix4x4,
  463.     TQ3Point3D                    *result);
  464.  
  465. QD3D_EXPORT TQ3RationalPoint4D *QD3D_CALL Q3RationalPoint4D_Transform(
  466.     const TQ3RationalPoint4D    *point4D, 
  467.     const TQ3Matrix4x4            *matrix4x4,
  468.     TQ3RationalPoint4D            *result);
  469.     
  470. QD3D_EXPORT TQ3Status QD3D_CALL Q3Point3D_To3DTransformArray(
  471.     const TQ3Point3D             *inPoint3D, 
  472.     const TQ3Matrix4x4             *matrix,
  473.     TQ3Point3D                     *outPoint3D,  
  474.     long                         numPoints, 
  475.     unsigned long                 inStructSize, 
  476.     unsigned long                 outStructSize);
  477.     
  478. QD3D_EXPORT TQ3Status QD3D_CALL Q3Point3D_To4DTransformArray(
  479.     const TQ3Point3D             *inPoint3D, 
  480.     const TQ3Matrix4x4             *matrix,
  481.     TQ3RationalPoint4D             *outPoint4D,  
  482.     long                         numPoints,
  483.     unsigned long                 inStructSize, 
  484.     unsigned long                 outStructSize);
  485.     
  486. QD3D_EXPORT TQ3Status QD3D_CALL Q3RationalPoint4D_To4DTransformArray(
  487.     const TQ3RationalPoint4D     *inPoint4D, 
  488.     const TQ3Matrix4x4             *matrix,
  489.     TQ3RationalPoint4D             *outPoint4D,  
  490.     long                         numPoints, 
  491.     unsigned long                 inStructSize, 
  492.     unsigned long                 outStructSize);
  493.  
  494.  
  495. /******************************************************************************
  496.  **                                                                             **
  497.  **                                Vector Negation                                 **
  498.  **                                                                             **
  499.  *****************************************************************************/
  500.  
  501. QD3D_EXPORT TQ3Vector2D *QD3D_CALL Q3Vector2D_Negate(
  502.     const TQ3Vector2D            *vector2D,
  503.     TQ3Vector2D                    *result);
  504.  
  505. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_Negate(
  506.     const TQ3Vector3D            *vector3D,
  507.     TQ3Vector3D                    *result);
  508.  
  509.  
  510. /******************************************************************************
  511.  **                                                                             **
  512.  **                    Point conversion from cartesian to polar                 **
  513.  **                                                                             **
  514.  *****************************************************************************/
  515.  
  516. QD3D_EXPORT TQ3PolarPoint *QD3D_CALL Q3Point2D_ToPolar(
  517.     const TQ3Point2D            *point2D,
  518.     TQ3PolarPoint                *result);
  519.     
  520. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3PolarPoint_ToPoint2D(
  521.     const TQ3PolarPoint            *polarPoint,
  522.     TQ3Point2D                    *result);
  523.     
  524. QD3D_EXPORT TQ3SphericalPoint *QD3D_CALL Q3Point3D_ToSpherical(
  525.     const TQ3Point3D            *point3D,
  526.     TQ3SphericalPoint            *result);
  527.     
  528. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3SphericalPoint_ToPoint3D(
  529.     const TQ3SphericalPoint        *sphericalPoint,
  530.     TQ3Point3D                    *result);
  531.  
  532.  
  533. /******************************************************************************
  534.  **                                                                             **
  535.  **                            Point Affine Combinations                         **
  536.  **                                                                             **
  537.  *****************************************************************************/
  538.  
  539. QD3D_EXPORT TQ3Point2D *QD3D_CALL Q3Point2D_AffineComb(
  540.     const TQ3Point2D            *points2D,
  541.     const float                    *weights,
  542.     unsigned long                nPoints, 
  543.     TQ3Point2D                    *result);
  544.  
  545. QD3D_EXPORT TQ3Param2D *QD3D_CALL Q3Param2D_AffineComb(
  546.     const TQ3Param2D            *params2D,
  547.     const float                    *weights,
  548.     unsigned long                nPoints, 
  549.     TQ3Param2D                    *result);
  550.  
  551. QD3D_EXPORT TQ3RationalPoint3D *QD3D_CALL Q3RationalPoint3D_AffineComb(
  552.     const TQ3RationalPoint3D    *points3D,
  553.     const float                    *weights,
  554.     unsigned long                numPoints, 
  555.     TQ3RationalPoint3D            *result);
  556.     
  557. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point3D_AffineComb(
  558.     const TQ3Point3D            *points3D,
  559.     const float                    *weights,
  560.     unsigned long                numPoints, 
  561.     TQ3Point3D                    *result);
  562.  
  563. QD3D_EXPORT TQ3RationalPoint4D *QD3D_CALL Q3RationalPoint4D_AffineComb(
  564.     const TQ3RationalPoint4D    *points4D,
  565.     const float                    *weights,
  566.     unsigned long                numPoints, 
  567.     TQ3RationalPoint4D            *result);
  568.     
  569.     
  570. /******************************************************************************
  571.  **                                                                             **
  572.  **                                Matrix Functions                             **
  573.  **                                                                             **
  574.  *****************************************************************************/
  575.  
  576. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_Copy(
  577.     const TQ3Matrix3x3            *matrix3x3,
  578.     TQ3Matrix3x3                *result);
  579.     
  580. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_Copy(
  581.     const TQ3Matrix4x4            *matrix4x4,
  582.     TQ3Matrix4x4                *result);
  583.  
  584.  
  585. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_SetIdentity(
  586.     TQ3Matrix3x3                *matrix3x3);
  587.  
  588. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetIdentity(
  589.     TQ3Matrix4x4                *matrix4x4);
  590.  
  591.  
  592. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_Transpose(
  593.     const TQ3Matrix3x3            *matrix3x3,
  594.     TQ3Matrix3x3                *result);
  595.  
  596. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_Transpose(
  597.     const TQ3Matrix4x4            *matrix4x4,
  598.     TQ3Matrix4x4                *result);
  599.  
  600.  
  601. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_Invert(
  602.     const TQ3Matrix3x3            *matrix3x3,
  603.     TQ3Matrix3x3                *result);
  604.  
  605. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_Invert(
  606.     const TQ3Matrix4x4            *matrix4x4,
  607.     TQ3Matrix4x4                *result);
  608.     
  609.     
  610. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_Adjoint(
  611.     const TQ3Matrix3x3            *matrix3x3,
  612.     TQ3Matrix3x3                *result);
  613.  
  614.  
  615. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_Multiply(
  616.     const TQ3Matrix3x3            *matrixA,
  617.     const TQ3Matrix3x3            *matrixB,
  618.     TQ3Matrix3x3                *result);
  619.  
  620. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_Multiply(
  621.     const TQ3Matrix4x4            *matrixA,
  622.     const TQ3Matrix4x4            *matrixB,
  623.     TQ3Matrix4x4                *result);
  624.  
  625.  
  626. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_SetTranslate(
  627.     TQ3Matrix3x3                *matrix3x3,    
  628.     float                        xTrans,
  629.     float                        yTrans);
  630.  
  631. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_SetScale(
  632.     TQ3Matrix3x3                *matrix3x3,
  633.     float                        xScale,
  634.     float                        yScale);
  635.  
  636.  
  637. QD3D_EXPORT TQ3Matrix3x3 *QD3D_CALL Q3Matrix3x3_SetRotateAboutPoint(
  638.     TQ3Matrix3x3                *matrix3x3,
  639.     const TQ3Point2D            *origin,
  640.     float                        angle);
  641.  
  642. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetTranslate(
  643.     TQ3Matrix4x4                *matrix4x4,
  644.     float                        xTrans,
  645.     float                        yTrans,
  646.     float                        zTrans);
  647.  
  648. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetScale(
  649.     TQ3Matrix4x4                *matrix4x4,
  650.     float                        xScale,
  651.     float                        yScale,
  652.     float                        zScale);
  653.  
  654.  
  655. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetRotateAboutPoint(
  656.     TQ3Matrix4x4                *matrix4x4,
  657.     const TQ3Point3D            *origin,
  658.     float                        xAngle,
  659.     float                        yAngle,
  660.     float                        zAngle);
  661.     
  662. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetRotateAboutAxis(
  663.     TQ3Matrix4x4                *matrix4x4,
  664.     const TQ3Point3D            *origin,
  665.     const TQ3Vector3D            *orientation,   
  666.     float                        angle);    
  667.     
  668. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetRotate_X(
  669.     TQ3Matrix4x4                *matrix4x4,
  670.     float                        angle);
  671.     
  672. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetRotate_Y(
  673.     TQ3Matrix4x4                *matrix4x4,
  674.     float                        angle);
  675.  
  676. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetRotate_Z(
  677.     TQ3Matrix4x4                *matrix4x4,
  678.     float                        angle);
  679.         
  680. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetRotate_XYZ(
  681.     TQ3Matrix4x4                *matrix4x4,
  682.     float                        xAngle,
  683.     float                        yAngle,
  684.     float                        zAngle);                            
  685.                             
  686. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetRotateVectorToVector(
  687.     TQ3Matrix4x4                *matrix4x4,
  688.     const TQ3Vector3D            *v1,
  689.     const TQ3Vector3D            *v2);
  690.  
  691. QD3D_EXPORT TQ3Matrix4x4 *QD3D_CALL Q3Matrix4x4_SetQuaternion(
  692.     TQ3Matrix4x4                 *matrix, 
  693.     const TQ3Quaternion         *quaternion);
  694.     
  695. QD3D_EXPORT float QD3D_CALL Q3Matrix3x3_Determinant(
  696.     const TQ3Matrix3x3            *matrix3x3);
  697.  
  698. QD3D_EXPORT float QD3D_CALL Q3Matrix4x4_Determinant(
  699.     const TQ3Matrix4x4            *matrix4x4);
  700.     
  701.     
  702. /******************************************************************************
  703.  **                                                                             **
  704.  **                                Quaternion Routines                             **
  705.  **                                                                             **
  706.  *****************************************************************************/
  707.  
  708. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_Set(
  709.     TQ3Quaternion                *quaternion,
  710.     float                        w,
  711.     float                        x,
  712.     float                        y,
  713.     float                        z);
  714.     
  715. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetIdentity(
  716.     TQ3Quaternion                *quaternion);
  717.     
  718. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_Copy(
  719.     const TQ3Quaternion            *quaternion, 
  720.     TQ3Quaternion                 *result);
  721.  
  722. QD3D_EXPORT TQ3Boolean QD3D_CALL Q3Quaternion_IsIdentity(
  723.     const TQ3Quaternion            *quaternion);
  724.  
  725. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_Invert(
  726.     const TQ3Quaternion         *quaternion,
  727.     TQ3Quaternion                *result);
  728.  
  729. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_Normalize(
  730.     const TQ3Quaternion            *quaternion,
  731.     TQ3Quaternion                *result);
  732.  
  733. QD3D_EXPORT float QD3D_CALL Q3Quaternion_Dot(
  734.     const TQ3Quaternion         *q1, 
  735.     const TQ3Quaternion         *q2);
  736.  
  737. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_Multiply(
  738.     const TQ3Quaternion            *q1, 
  739.     const TQ3Quaternion            *q2,
  740.     TQ3Quaternion                *result);
  741.  
  742. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetRotateAboutAxis(
  743.     TQ3Quaternion                 *quaternion, 
  744.     const TQ3Vector3D             *axis, 
  745.     float                         angle);
  746.     
  747.  
  748. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetRotate_XYZ(
  749.     TQ3Quaternion                 *quaternion, 
  750.     float                         xAngle, 
  751.     float                         yAngle, 
  752.     float                         zAngle);
  753.     
  754. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetRotate_X(
  755.     TQ3Quaternion                 *quaternion, 
  756.     float                         angle);
  757.  
  758. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetRotate_Y(
  759.     TQ3Quaternion                 *quaternion, 
  760.     float                         angle);
  761.  
  762. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetRotate_Z(
  763.     TQ3Quaternion                 *quaternion, 
  764.     float                         angle);
  765.  
  766.  
  767. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetMatrix(
  768.     TQ3Quaternion                 *quaternion, 
  769.     const TQ3Matrix4x4             *matrix);
  770.  
  771. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_SetRotateVectorToVector(
  772.     TQ3Quaternion                 *quaternion, 
  773.     const TQ3Vector3D             *v1, 
  774.     const TQ3Vector3D             *v2);
  775.  
  776. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_MatchReflection(
  777.     const TQ3Quaternion            *q1, 
  778.     const TQ3Quaternion         *q2,
  779.     TQ3Quaternion                *result);
  780.  
  781. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_InterpolateFast(
  782.     const TQ3Quaternion         *q1, 
  783.     const TQ3Quaternion         *q2, 
  784.     float                         t,
  785.     TQ3Quaternion                *result);
  786.  
  787. QD3D_EXPORT TQ3Quaternion *QD3D_CALL Q3Quaternion_InterpolateLinear(
  788.     const TQ3Quaternion         *q1, 
  789.     const TQ3Quaternion         *q2, 
  790.     float                         t,
  791.     TQ3Quaternion                 *result);
  792.  
  793. QD3D_EXPORT TQ3Vector3D *QD3D_CALL Q3Vector3D_TransformQuaternion(
  794.     const TQ3Vector3D             *vector3D, 
  795.     const TQ3Quaternion         *quaternion,
  796.     TQ3Vector3D                    *result);
  797.  
  798. QD3D_EXPORT TQ3Point3D *QD3D_CALL Q3Point3D_TransformQuaternion(
  799.     const TQ3Point3D             *point3D, 
  800.     const TQ3Quaternion         *quaternion,
  801.     TQ3Point3D                    *result);
  802.  
  803.  
  804. /******************************************************************************
  805.  **                                                                             **
  806.  **                                Volume Routines                                 **
  807.  **                                                                             **
  808.  *****************************************************************************/
  809.  
  810. QD3D_EXPORT TQ3BoundingBox *QD3D_CALL Q3BoundingBox_Copy(
  811.     const TQ3BoundingBox         *src, 
  812.     TQ3BoundingBox                 *dest);
  813.     
  814. QD3D_EXPORT TQ3BoundingBox *QD3D_CALL Q3BoundingBox_Union(
  815.     const TQ3BoundingBox         *v1, 
  816.     const TQ3BoundingBox         *v2,
  817.     TQ3BoundingBox                *result);
  818.     
  819. QD3D_EXPORT TQ3BoundingBox *QD3D_CALL Q3BoundingBox_Set(
  820.     TQ3BoundingBox                 *bBox,
  821.     const TQ3Point3D             *min, 
  822.     const TQ3Point3D             *max,
  823.     TQ3Boolean                    isEmpty);
  824.     
  825. QD3D_EXPORT TQ3BoundingBox *QD3D_CALL Q3BoundingBox_UnionPoint3D(
  826.     const TQ3BoundingBox         *bBox,
  827.     const TQ3Point3D             *point3D,
  828.     TQ3BoundingBox                *result);
  829.     
  830. QD3D_EXPORT TQ3BoundingBox *QD3D_CALL Q3BoundingBox_UnionRationalPoint4D(
  831.     const TQ3BoundingBox         *bBox,
  832.     const TQ3RationalPoint4D     *point4D, 
  833.     TQ3BoundingBox                 *result);
  834.  
  835. QD3D_EXPORT TQ3BoundingBox *QD3D_CALL Q3BoundingBox_SetFromPoints3D(
  836.     TQ3BoundingBox                 *bBox, 
  837.     const TQ3Point3D             *points3D, 
  838.     unsigned long                 numPoints,
  839.     unsigned long                structSize);
  840.     
  841. QD3D_EXPORT TQ3BoundingBox *QD3D_CALL Q3BoundingBox_SetFromRationalPoints4D(
  842.     TQ3BoundingBox                 *bBox, 
  843.     const TQ3RationalPoint4D     *points4D, 
  844.     unsigned long                 numPoints,
  845.     unsigned long                structSize);
  846.  
  847.  
  848. /******************************************************************************
  849.  **                                                                             **
  850.  **                                Sphere Routines                                 **
  851.  **                                                                             **
  852.  *****************************************************************************/
  853.  
  854. QD3D_EXPORT TQ3BoundingSphere *QD3D_CALL Q3BoundingSphere_Copy(
  855.     const TQ3BoundingSphere     *src, 
  856.     TQ3BoundingSphere             *dest);
  857.     
  858. QD3D_EXPORT TQ3BoundingSphere *QD3D_CALL Q3BoundingSphere_Union(
  859.     const TQ3BoundingSphere     *s1, 
  860.     const TQ3BoundingSphere     *s2,
  861.     TQ3BoundingSphere            *result);
  862.  
  863. QD3D_EXPORT TQ3BoundingSphere *QD3D_CALL Q3BoundingSphere_Set(
  864.     TQ3BoundingSphere             *bSphere,
  865.     const TQ3Point3D             *origin, 
  866.     float                        radius,
  867.     TQ3Boolean                    isEmpty);
  868.     
  869. QD3D_EXPORT TQ3BoundingSphere *QD3D_CALL Q3BoundingSphere_UnionPoint3D(
  870.     const TQ3BoundingSphere     *bSphere,
  871.     const TQ3Point3D             *point3D,
  872.     TQ3BoundingSphere            *result);
  873.     
  874. QD3D_EXPORT TQ3BoundingSphere *QD3D_CALL Q3BoundingSphere_UnionRationalPoint4D(
  875.     const TQ3BoundingSphere     *bSphere,
  876.     const TQ3RationalPoint4D     *point4D, 
  877.     TQ3BoundingSphere             *result);
  878.  
  879.     
  880. QD3D_EXPORT TQ3BoundingSphere *QD3D_CALL Q3BoundingSphere_SetFromPoints3D(
  881.     TQ3BoundingSphere             *bSphere, 
  882.     const TQ3Point3D             *points3D, 
  883.     unsigned long                 numPoints,
  884.     unsigned long                structSize);
  885.     
  886. QD3D_EXPORT TQ3BoundingSphere *QD3D_CALL Q3BoundingSphere_SetFromRationalPoints4D(
  887.     TQ3BoundingSphere             *bSphere, 
  888.     const TQ3RationalPoint4D     *points4D, 
  889.     unsigned long                 numPoints,
  890.     unsigned long                structSize);    
  891.  
  892.  
  893. #ifdef __cplusplus
  894. }
  895. #endif    /* __cplusplus */
  896.  
  897. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  898.  
  899. #if defined(__xlc__) || defined(__XLC121__)
  900.     #pragma options enum=reset
  901.     #pragma options align=reset
  902. #elif defined(__MWERKS__)
  903.     #pragma enumsalwaysint reset
  904.     #pragma options align=reset
  905. #elif defined(__MRC__) || defined(__SC__)
  906.     #if PRAGMA_ENUM_RESET_QD3DMATH
  907.         #pragma options(pack_enums)
  908.         #undef PRAGMA_ENUM_RESET_QD3DMATH
  909.     #endif
  910.     #pragma options align=reset
  911. #endif
  912.  
  913. #endif  /* OS_MACINTOSH */
  914.  
  915. #endif  /*  QD3DMath_h  */
  916.